package com.lemon.smartsafetynew.ui.adapter.patrol;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.lemon.smartsafety.R;
import com.lemon.smartsafetynew.entity.patrol.SafePatrolTaskItemVo;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import kale.adapter.LemonRcvAdapter;
import kale.adapter.item.AdapterItem;

/**
 * Created by Andrew on 2017/9/19.
 */

public class PatrolResultAdapter extends LemonRcvAdapter<SafePatrolTaskItemVo> {

    public PatrolResultAdapter(@Nullable List<SafePatrolTaskItemVo> data) {
        super(data);
    }

    @NonNull
    @Override
    public AdapterItem createItem(Object type) {
        return new ItemAdapter();
    }

    public class ItemAdapter implements AdapterItem<SafePatrolTaskItemVo> {

        @Bind(R.id.safe_patrol_item_status_ImageView)
        ImageView safePatrolItemStatusImageView;
        @Bind(R.id.white_top_line_view)
        View whiteTopLineView;
        @Bind(R.id.white_bottom_line_view)
        View whiteBottomLineView;
        @Bind(R.id.safe_patrol_item_name_tv)
        TextView safePatrolItemNameTv;
        @Bind(R.id.safe_patrol_item_desc_tv)
        TextView safePatrolItemDescTv;
        @Bind(R.id.qr_ImageView)
        ImageView qrImageView;
        @Bind(R.id.nfc_ImageView)
        ImageView nfcImageView;
        @Bind(R.id.safe_patrol_point_imageView)
        ImageView safePatrolPointImageView;
        @Bind(R.id.arrow_imageView)
        ImageView arrowImageView;

        @Override
        public int getLayoutResId() {
            return R.layout.item_safe_patrol_task_item;
        }

        @Override
        public void bindViews(View root) {
            ButterKnife.bind(this, root);
        }

        @Override
        public void setViews() {

        }

        @Override
        public void handleData(SafePatrolTaskItemVo patrolTaskItemVo, int position) {

            qrImageView.setVisibility(View.GONE);
            nfcImageView.setVisibility(View.GONE);
            arrowImageView.setVisibility(View.INVISIBLE);
            safePatrolItemStatusImageView.setVisibility(View.GONE);
            whiteTopLineView.setVisibility(View.VISIBLE);
            whiteBottomLineView.setVisibility(View.VISIBLE);


            safePatrolItemNameTv.setText(patrolTaskItemVo.getObject_title());
            safePatrolItemDescTv.setText(patrolTaskItemVo.getBuilding_name()
                    + " - "
                    + patrolTaskItemVo.getFloor_number() + "楼 "
                    + patrolTaskItemVo.getPosition_name());

            if(patrolTaskItemVo.getIs_patrol() == 1) { // 1： 巡更点
                safePatrolPointImageView.setVisibility(View.VISIBLE);
            } else {
                safePatrolPointImageView.setVisibility(View.INVISIBLE);
            }

        }

    }
}
